using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebControls;
using InfraStructureLayer;
using EntityLayer;
using BusinessLayer;

public partial class Admin_login : SFPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        this.Validate();
        if (this.HasErrors)
        {
            MessageBoxShow(this);
            return;
        }
        entUsers insEntUsers = new entUsers();
        busUsers insBusUsers = new busUsers();
        insEntUsers.UserName = txtUserName.Text;
        insEntUsers.UserPassword = txtPassword.Text;
        insBusUsers.SelectUsersByUserNameAndUserPassword(insEntUsers);
        if (insEntUsers.UserId == 0)
        {
            MessageBoxShow(StaticMethods.GetErrorMessageMultilanguageString(25, new object[] { }));
            return;
        }
        else
        {
            CurrentContext.UserId = insEntUsers.UserId;
        }
        
        if (Request.QueryString["ReturnPath"] == null || Request.QueryString["ReturnPath"] == "")
        {
            Response.Redirect("default.aspx");
        }
        else
        {
            Response.Redirect(Request.QueryString["ReturnPath"]);
        }
    }
}
